﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AMS.Core.Services;

namespace AMS.DD35.ServiceLib.Tests
{
    class MockSessionService : ISessionService
    {
        string validSession = "validSession";
        string validIdentifer = "validIdentifier";

        public TimeSpan Timeout { set; get; }

        public event EventHandler<TimeoutEventArgs> TimedOut;
        
        public object StartSession(string identifier)
        {
            return validSession;
        }

        public bool HasSession(string identifier)
        {
            return identifier == validIdentifer;
        }

        public bool IsValidSession(string identifier, object sessionVariable)
        {
            return identifier == validIdentifer && sessionVariable == validSession;
        }

        public bool IsValidSession(object sessionVariable)
        {
            return sessionVariable == validSession;
        }

        public void UpdateSession(object sessionVariable)
        {
            // updates time
        }

        public void EndSession(object sessionVariable)
        {
            if (validSession == (string)sessionVariable)
                validSession = null;
        }

        public string ResolveIdentifier(object sessionVariable)
        {
            if (validSession == (string)sessionVariable)
                return validSession;

            return null;
        }
    }
}
